#pragma once

#include <vector>
#include "StationInfo.h"

class StationManager
{
public:
	StationManager();
	~StationManager(void);

	void AddNewStation(const CString& StationName,
					   const CString& SerialNumber,
					   const CString& UniformSerialNumber);
	void DeleteStation(size_t nIndex);

	void ModifyStation(size_t nIndex,
					   const CString& StationName,
					   const CString& SerailNumber,
					   const CString& UniformSerialNumber);

	
	
	
	/********************************************************/
	size_t Size(){ return siArray.size();}
	/********************************************************/
	const StationInfo& GetAt(size_t nIndex)
	{
		ASSERT( nIndex < siArray.size());
		return *siArray[nIndex];
	}
	/********************************************************/
	int  FindStation(char* downloaded);
private:
	CString strDBPATH;
	
	std::vector<StationInfo*> siArray;
	HANDLE m_hStopEvent;
private:
	
	bool IsAddName_AlreadyExist(char* szName);
	bool IsAddSerialNumber_AlreadyExist(char* szSN);
	bool IsAddUniformSerialNumber_AlreadyExist(char* szUSN);

	bool IsModifiedName_AlreadyExist(int pos,char* szName);
	bool IsModifiedSerialNumber_AlreadyExist(int pos,char* szSN);
	bool IsModifiedUniformSerialNumber_AlreadyExist(int pos,char* szUSN);

	
	//bool Is
	void Init();
	CString GetDBPATH();//  \current dir\DataBase\

	void LoadStationInfo(const CString& strStationPath);
	void LoadStationInfo();
	
	CString LoadStationName(const CString& strStationPath);
	CString LoadSerialNumber(const CString& strStationPath);
	CString LoadUniformSerialNumber(const CString& strStationPath);
	COleDateTime LoadLastRecordTime(const CString& strStationPath);
	float   LoadLastRecordValue(const CString& strStationPath);

	
};
